package com.guan.spring.springDI.cycleDenpdcy;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class MainApplication {

    public static void main(String[] args) {

        // 初始化Spring容器
        AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext(AppConfig.class);

        // 获取BookService Bean
        BookService bookService = (BookService) annotationConfigApplicationContext.getBean("bookService");
        System.out.println(bookService); // 输出BookService及其依赖的AuthorService

        // 获取AuthorService Bean
        AuthorService authorService = (AuthorService) annotationConfigApplicationContext.getBean("authorService");
        System.out.println(authorService); // 输出AuthorService及其依赖的BookService

        // 关闭Spring容器
        annotationConfigApplicationContext.close();
    }
}
